<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script type="text/javascript">
    //调用微信JS api 支付
    function jsApiCall()
    {
        WeixinJSBridge.invoke(
                'getBrandWCPayRequest',
                <?php echo $jsApiParameters; ?>,
    function(res){
//					alert(JSON.stringify(res));
//                    alert(res.err_msg)
        // WeixinJSBridge.log(res.err_msg);
        if(res.err_msg == "get_brand_wcpay_request:ok"){
//                        alert(1)
        /*这里写如果支付成功的话执行什么操作*/
//						alert('支付成功'+JSON.stringify(res));
        wstMsg('下单成功');
        setTimeout(function(){
        location.href = WST.U('WebApp/Orders/index');
    }, 500);
        storageRemoveItem('orderInfo');
    }else{
        //返回跳转到订单详情页面
        alert('支付失败');

    }
    }
    );
    }
    function callpay()
    {
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
            }
        }else{
            jsApiCall();
        }
    }

</script>
<body>

<div style="width:100px;height:50px;background: yellow">
    <button type="button" onclick="jsApiCall()">Buy!</button>
</div>


</body>
</html>